--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Commit 5739b33f06923211873b26a2e0bfeed4ae058877
Parents : 1f1cb5c
Author : Mark Qvist <mark@unsigned.io>
Date : 2022-11-23T20:42:56+01:00
Fixed bluetooth permissions on API levels < 30
Changes
4 files changed, 14 insertions(+), 5 deletions(-)
Diff
diff --git a/sbapp/main.py b/sbapp/main.py
index 4a45b2f3..72cbf0c0 100644
--- a/sbapp/main.py
+++ b/sbapp/main.py
@@ -377,7 +377,12 @@ class SidebandApp(MDApp):
mActivity = autoclass('org.kivy.android.PythonActivity').mActivity
Context = autoclass('android.content.Context')
- if check_permission("android.permission.BLUETOOTH_CONNECT"):
+ if android_api_version > 30:
+ bt_permission_name = "android.permission.BLUETOOTH_CONNECT"
+ else:
+ bt_permission_name = "android.permission.BLUETOOTH"
+
+ if check_permission(bt_permission_name):
RNS.log("Have bluetooth connect permissions", RNS.LOG_DEBUG)
self.sideband.setpersistent("permissions.bluetooth", True)
else:
diff --git a/sbapp/patches/AndroidManifest.tmpl.xml b/sbapp/patches/AndroidManifest.tmpl.xml
index cf24d44e..f8867634 100644
--- a/sbapp/patches/AndroidManifest.tmpl.xml
+++ b/sbapp/patches/AndroidManifest.tmpl.xml
@@ -27,6 +27,9 @@
<!-- Allow writing to external storage -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+ <uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
+ <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" />
+
{% for perm in args.permissions %}
{% if '.' in perm %}
<uses-permission android:name="{{ perm }}" />
diff --git a/sbapp/services/sidebandservice.py b/sbapp/services/sidebandservice.py
index 478d3a99..8c8f1cf2 100644
--- a/sbapp/services/sidebandservice.py
+++ b/sbapp/services/sidebandservice.py
@@ -1,4 +1,4 @@
-__debug_build__ = False
+__debug_build__ = True
import time
import RNS
diff --git a/sbapp/sideband/core.py b/sbapp/sideband/core.py
index 060adacc..adf72ae4 100644
--- a/sbapp/sideband/core.py
+++ b/sbapp/sideband/core.py
@@ -1551,6 +1551,8 @@ class SidebandCore():
else:
target_port = None
+ bt_device_name = None
+ rnode_allow_bluetooth = False
if self.getpersistent("permissions.bluetooth"):
if self.config["hw_rnode_bluetooth"]:
# TODO: Remove
@@ -1558,8 +1560,7 @@ class SidebandCore():
rnode_allow_bluetooth = True
if self.config["hw_rnode_bt_device"] != None:
bt_device_name = self.config["hw_rnode_bt_device"]
- else:
- bt_device_name = None
+
else:
# TODO: Remove
RNS.log("Disallowing RNode bluetooth since config is disabled")
@@ -1567,7 +1568,7 @@ class SidebandCore():
else:
# TODO: Remove
RNS.log("Disallowing RNode bluetooth due to missing permission")
- rnode_allow_bluetooth = True
+ rnode_allow_bluetooth = False
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────